<?php 

// sicherheit
session_start();
if ($_SESSION['angemeldet'] != true){

require_once('admin.inc');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
      session_start();
      $password = $_POST['psw'];
	  if ($password==$psw){
	  	$_SESSION['angemeldet'] = true;
	  }else die('Wrong password!');

}else die('Cannot log in');
}

// Dokument laden mit Informaionen aller Schulen
    $masterDoc = new DomDocument('1.0', 'utf-8');
    $filename = '../content/languageschools/master.xml';
	$masterDoc->Load($filename);
	if(file_exists($filename)) {
		$masterDoc->Load($filename);
	}else die ("Konnte XML Datei nicht öffnen");
	

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Admin Menü</title>
</head>
<link href="style.css" rel="stylesheet" type="text/css">
<div class="menubox">
<h2> Willkommen zum Administrator Bereich von private-language-school.com<br /><br />
</h2>
<div align="center">
<table border="0">
  <tr>
    <td width="97">&nbsp;</td>
    <td width="139">
    <h3>Neue Schule anlegen</h3>
    <form name="anlegen" method="post" action="schulebearbeiten.php">
	<input type="submit" name="button" id="button" value="Neue Schule anlegen">
</form></td>
<td width="34"></td>
    <td width="133">
    <h3>&nbsp;</h3>
 </td>
  </tr>
  <tr>
    <td colspan="4"><h2>Vorhandene Schule bearbeiten</h2>
      <table width="100%" border="0" class="schooltable">
        <tr>
          <td width="27"><strong>Id</strong></td>
          <td width="134"><strong>Land</strong></td>
          <td width="174"><strong>Ort</strong></td>
          <td width="108"><strong>Sprachschule löschen</strong></td>
        </tr>
      
              <?php

	$schoolSet = $masterDoc->getElementsByTagName('school');
	$highestid = 0;
	require_once ("../scripts/php/languageschool.php");
	foreach( $schoolSet as $school )
	{
		// create school out of give schoolid
    	$schoolId = $school->getElementsByTagName( 'id' )->item(0)->nodeValue;
		$theschool =  new School($schoolId);
		$schoolTitle = $school->getElementsByTagName( 'title' )->item(0)->nodeValue;
		$nid = $schoolId;
		if ($nid <10)$nid = "0".$nid;
		echo "<tr>
       				   <td><a href=schulebearbeiten.php?schoolid=".$schoolId.">".$nid."</a></td>
		    	       <td><a href=schulebearbeiten.php?schoolid=".$schoolId.">".$theschool->getCountry()."</a></td>
   		    	       <td><a href=schulebearbeiten.php?schoolid=".$schoolId.">".$theschool->getCity()."</a></td>
					   <td><a href=loescheschule.php?schoolid=".$schoolId.">löschen</a></td>
        	</tr>";
	} 

	?>
      
       
      </table>

      <form id="logout" name="logout" method="post" action="logout.php">
        <div align="center">      <input name="log" type="submit"  value="logout"/></div>
    </form>
    </td>
    </tr>
</table>
</div>
<br /><br />

</div>
